def H(Q):
    B = []
    A = "([{"
    C = ")]}"
    D = {"(": ")", "[": "]", "{": "}"}

    for K in Q:
        if K in A:
            B.append(K)
        elif K in C:
            if not B or D[B.pop()] != K:
                return False

    return len(B) == 0

S = input()
R = H(S)
print(R)